<template>
	<view style="overflow: hidden;" v-if="list.length > 0">
		<view class="messageCard" v-for="(item,index) in list" :key="index">
			<view class="groupInfo">
				<view class="headImg">
					<image :src="item.groupAvatar" mode="aspectFill"></image>
				</view>
				<view class="groupName">
					{{item.groupName}}
				</view>
			</view>
			<view class="messageInfo">
				<view class="successInfo" v-if="item.status===0">
					您已成功加入排位
				</view>
				<view class="successInfo" v-if="item.status===1">
					恭喜您排到了心仪的谷子！！！已为您生成订单
				</view>
				<view class="failInfo" v-if="item.status===2">
					很遗憾，您暂未排到您心仪的谷子
				</view>
			</view>
			<view class="goodsInfo" v-if="item.status===1" @click="goOrderDetail(item.orderId)"> 
				<view class="goodsCover">
					<image :src="item.goodsCover" mode="widthFix"></image>
				</view>
				<view class="goodsRole">
					<view class="goodsName">
						{{item.goodsName}}
					</view>
					<view class="role">
						<view class="roleName">
							{{item.goodsRoleName}}
						</view>
						<view class="roleNum">
							×{{item.finalBuyNum}}
						</view>
					</view>
					<view class="totalPrice">
						￥{{item.totalPrice}}
					</view>
				</view>
			</view>
		</view>
	</view>
	<view v-else class="other">
		{{title}}
	</view>
</template>

<script>
	export default {
		name:"messageCard",
		props: ['list'],
		data() {
			return {
				title:"暂无您的消息",
			};
		},
		methods: {
			goOrderDetail(id){
				uni.navigateTo({
					url:`/pages/orderDetail/orderDetail?orderId=${id}`,
				})
			}
		}
	}
</script>

<style lang="scss">
.other {
	display: flex;
	width: 100vw;
	height: 100vh;
	justify-content: center;
	align-items: center;
	color: #333;
}
.messageCard{
	margin: 20rpx;
	padding: 20rpx 20rpx 20rpx 30rpx;
	background-color: #fff;
	border-radius: 16rpx;
	border: 1rpx solid #ddd;
	box-shadow: 0 0 4px 1px rgba(0, 0, 0, 0.1);
	.groupInfo{
		display: flex;
		width: 100%;
		height: 50rpx;
		line-height: 50rpx;
		font-size: 22rpx;
		margin:0 0 20rpx 8rpx;
		.headImg{
			width: 50rpx;
			height: 50rpx;
			border-radius: 50%;
			margin-right: 20rpx;
			overflow: hidden;
			image{
				width: 100%;
				height: 100%;
			}
		}
	}
	.messageInfo{
		color:#8DC7DF;
		font-size: 34rpx;
		margin-left: 8rpx;
		.failInfo{
			color: #000;
			font-weight: 500;
			font-size: 28rpx;
		}
	}
	.goodsInfo{
		display: flex;
		position: relative;
		font-size: 30rpx;
		margin: 20rpx 0 0 20rpx;
		.goodsCover{
			width: 200rpx;
			image{
				width: 100%;
			}
		}
		.goodsRole{
			display: flex;
			flex-direction: column;
			justify-content: space-around;
			margin-left: 40rpx;
			.role{
				display: flex;
				.roleNum{
					margin-left: 16rpx;
				}
			}
			.totalPrice{
				color: red;
			}
		}
		.confirmBtn{
			position: absolute;
			right: 16rpx;
			bottom: 16rpx;
			height: 50rpx;
			line-height: 50rpx;
			font-size: 30rpx;
			color: #8DC7DF;
			border:1rpx solid  #E3F1F7;
			padding: 6rpx 18rpx;
			border-radius: 20rpx;
		}
	}
}
</style>